import Vue from 'vue';
import VueRouter from 'vue-router';

const originalPush = VueRouter.prototype.push;
VueRouter.prototype.push = function push(location) {
	return originalPush.call(this, location).catch(err => err);
};

const originalReplace = VueRouter.prototype.replace;
VueRouter.prototype.replace = function replace(location) {
	return originalReplace.call(this, location).catch(err => err);
};

Vue.use(VueRouter);

const routes = [
	{name: 'Index', path: '/index', component: () => import('@/views/Index')},
	{
		name: 'Auth', path: '/auth', component: () => import('@/views/PageView'), children: [
			{name: 'Login', path: 'login', component: () => import('@/views/auth/Login')},
			{name: 'ForgetPassword', path: 'forget/password', component: () => import('@/views/auth/ForgetPassword')}
		]
	},
	// {
		// name: 'Admin', path: '/admin', component: () => import('@/components/layout/AdminLayout'), children: [
		// 	{name: 'Dashboard', path: 'dashboard', component: () => import('@/views/admin/Dashboard')},
		// 	{name: 'Menu', path: 'menu', component: () => import('@/views/admin/Menu')},
		// 	{name: 'Users', path: 'users', component: () => import('@/views/admin/User')},
		// 	{name: 'Role', path: 'role', component: () => import('@/views/admin/Role')}
		// ]
	// },
	{path: '*', redirect: {name: 'Index'}}
];

export default new VueRouter({
	mode: 'history',
	base: '/',
	routes,
	scrollBehavior: () => ({y: 0})

});